package com.tanhua.server.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.tanhua.dubbo.server.api.RecommendUserApi;
import com.tanhua.dubbo.server.pojo.RecommendUser;
import com.tanhua.dubbo.server.vo.PageInfo;
import com.tanhua.server.vo.TodayBest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: ly
 * @Date: 2021/07/29/21:31
 * @Description:
 */
@Service
public class RecommendUserService {

    @Reference(version = "1.0.0")
    private RecommendUserApi recommendUserApir;


    public TodayBest queryTodayBest(Long userId) {
        RecommendUser recommendUser = recommendUserApir.queryWithMaxScore(userId);
        if (recommendUser==null){
            //今日佳人查询失败，
            return  null;
        }

        TodayBest todayBest=new TodayBest();
        todayBest.setId(recommendUser.getUserId());

        //设置缘分值
        double score = Math.floor(recommendUser.getScore()); //向下取整
        todayBest.setFateValue(Double.valueOf(score).longValue());


        return  todayBest;
    }



    public PageInfo<RecommendUser> queryRecommendUserList(Long userId , Integer page , Integer pageSize) {


        return  recommendUserApir.queryPageInfo(userId, page, pageSize);

    }
}
